const logManager = require('./src/utils/logManager');

// 模拟Socket.IO
const mockIo = {
  to: (room) => ({
    emit: (event, data) => {
      console.log(`📡 [${room}] ${event}:`, data);
    }
  })
};

// 初始化日志管理器
logManager.init(mockIo);

// 测试日志功能
const projectId = 'test-project-123';

console.log('🧪 测试日志管理器功能...\n');

// 测试不同类型的日志
logManager.sendBuildStart(projectId, {
  nodeVersion: 'node14',
  buildStrategy: 'docker',
  platform: 'mp-weixin'
});

logManager.sendBuildStep(projectId, '配置', 'Node 14.21.3, Docker模式');
logManager.sendDockerLog(projectId, '拉取Docker镜像 node:14.21.3-alpine');
logManager.sendDependencyLog(projectId, '安装依赖包...');
logManager.sendDockerLog(projectId, '构建Docker容器');
logManager.sendBuildStep(projectId, '构建', '执行 npm run build:mp-weixin');
logManager.sendPackageLog(projectId, '打包构建产物...');
logManager.sendBuildSuccess(projectId, {
  outputDir: 'dist/build/mp-weixin',
  fileSize: '2.5MB'
});

console.log('\n✅ 日志测试完成！');
console.log('📋 日志历史:', logManager.getBuildLogs(projectId).length, '条记录');
